import { Body, Controller, Get, Post, Query } from '@nestjs/common';

import { ApiOperation, ApiTags } from '@nestjs/swagger';

import { QueryProductDto, DeleteStorageDto } from './storage.dto';
import { StorageService } from './storage.service';

@ApiTags('Tools - 存储模块')
@Controller('storage')
export class StorageController {
  constructor(private storageService: StorageService) {}

  @Get('list')
  @ApiOperation({ summary: '获取本地存储列表' })
  async list(@Query() dto: QueryProductDto) {
    return this.storageService.list(dto);
  }

  @ApiOperation({ summary: '删除文件' })
  @Post('delete')
  async delete(@Body() dto: DeleteStorageDto): Promise<void> {
    await this.storageService.delete(dto.ids);
  }
}
